<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="demo">

    </div>
    <script>
        const Hello = Vue.extend({
            name: 'Hello',
            template: `
            <div>
                <h3>Hello组件</h3>
                <p>hi, 你好！</p>
            </div>
            `
        })
        const Student = Vue.extend({
            name: 'Student',// 名字是在控制台中显示的，首字母大小写都可以，但是显示最终都是大写
            components: { Hello },
            data() {
                return {
                    name: '老张',
                    age: 20
                }
            },
            methods: {
                addAge() {
                    this.age += 1
                }
            },
            template: `
                <div>
                    <h3>学生</h3>
                    <p>name:{{name}}</p>
                    <p>age: {{age}}</p>
                    <p><button @click="addAge">age++</button></p>
                    <hr/>
                    <Hello/>
                </div>
                `
        })

        const School = Vue.extend({
            name: 'School',
            components:{Hello},
            data() {
                return {
                    name: '尚硅谷',
                    address: '宏福科技园'
                }
            },
            template: `
            <div>
                <h3>学校组件</h3>
                <p>name:{{name}}</p>
                <p>address:{{address}}</p>
                <p><button @click="address+='!'">address+ '!'</button></p>
                <hr/>
                <Hello/>
            </div>
            `
        })


        Vue.config.productionTip = false
        new Vue({
            el: '#demo',
            components: {
                Student,
                School
            },
            data: {},
            template: `
                    <div>
                        <h3>VM</h3>
                        <hr/>
                        <Student/>
                        <hr/>
                        <School/>
                    </div>
                `
        })
    </script>
</body>

</html>